//
//  MHSettingListController.m
//  ManHua
//
//  Created by 赵永泉 on 15/10/29.
//  Copyright © 2015年 蓝欧科技. All rights reserved.
//

#import "MHSettingListController.h"
#import "MHMySettingsViewController.h"
#import <MessageUI/MessageUI.h>

@interface MHSettingListController ()
@property (weak, nonatomic) IBOutlet UISwitch *lightSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *autoSwitch;

@end

@implementation MHSettingListController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [_lightSwitch addTarget:self action:@selector(changeLight:) forControlEvents:UIControlEventValueChanged];
    [_autoSwitch addTarget:self action:@selector(autoReadNext:) forControlEvents:UIControlEventValueChanged];
}


- (void)changeLight:(UISwitch *)sender
{
    if (sender.isOn) {
        [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    }
    else
    {
        [[ UIApplication sharedApplication] setIdleTimerDisabled:NO];
    }
    
}

// 发送通知给显示漫画的地方
- (void)autoReadNext:(UISwitch *)sender
{
    [[NSNotificationCenter defaultCenter]postNotificationName:@"isAllowPageUp" object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:sender.isOn] forKey:@"switchState"]];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            [self clearImageCash];
        }
        else if (indexPath.row == 1)
        {
            [self clearAllCash];
        }
    }
    else if (indexPath.section == 1)
    {
        if (indexPath.row == 0) {
            NSLog(@"给我们评分");
        }
        else if (indexPath.row == 1)
        {
            NSLog(@"免责声明");
            [self pushDetailVC:indexPath.row title:@"免责声明"];
        }
        else if (indexPath.row == 2)
        {
            NSLog(@"页面转码声明");
            [self pushDetailVC:indexPath.row title:@"页面转码声明"];
        }
        else if (indexPath.row == 3)
        {
            NSLog(@"版权申诉");
            self.sendEMailBlock();
        }
        else if (indexPath.row == 4)
        {
            NSLog(@"隐私政策");
            [self pushDetailVC:indexPath.row title:@"隐私政策"];
        }
    }
}

- (void)pushDetailVC:(NSInteger)row title:(NSString *)title
{
    MHSettingDetailViewController *detailVC = [[MHSettingDetailViewController alloc]init];
    detailVC.tagG = row;
    detailVC.titleN = title;
    // bloc返回到mySettingVC
    self.goSettingsDetailVCBlock(detailVC);
    
    
}

- (void)clearImageCash
{
    NSLog(@"clearImageCash");
}

- (void)clearAllCash
{
    NSLog(@"clearAllCash");
}


@end
